﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.BizTalk.Bam.EventObservation;
using System.IO;
using System.Runtime.Serialization;
using Microsoft.XLANGs.BaseTypes;


namespace BizTalk.ESB.Extensions.Itinerary.Helpers
{

    [Serializable]
    public class BizTalkMessageCustom
    {
        public static string MessageToString(XLANGMessage message)
        {
            string strResults;
            try
            {
                using (Stream stream = message[0].RetrieveAs(typeof(Stream)) as Stream)
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        strResults = reader.ReadToEnd();
                    }
                }
            }
            finally
            {
                message.Dispose();
            }
            return strResults;
        }
    }
}
